home *** CD-ROM | disk | FTP | other *** search
/ PC Zone 86 / PC Zone #086.7z / Dppcz0200.mdf / Editor.ial / Messiah / messiahpatch.exe / data1.cab / Program_Executable_Files / messiahscripts / Enemies / ArmdBeast.hxx < prev    next >
Text File  |  1999-11-28  |  20KB  |  792 lines

  1. //armored beast
  2.  
  3.         float(_declare,heavylandfx,0);
  4.         float(_declare,heavylandfx2,0);
  5.  
  6.         float(_declare,ShootDelayCounter,10000)
  7.         float(_declare,JumpIdleCounter,0);
  8.         float(_declare,JumpPressCounter,0);
  9.         float(_declare,DownwardPull,0);
  10.         float(_declare,TurnSpeed,0);
  11.         float(_declare,ColAngleCorrectNeeded,0);
  12.         float(_declare,ForceRunFrames,0);
  13.         float(_declare,AirSpeedForward,0);
  14.         float(_declare,AirSpeedSideways,0);
  15.         float(_declare,FallStartAltitude,0);
  16.         float(_declare,SmokeCount,1000);
  17.         float(_declare,FireCount,0);
  18.         float(_declare,ActionOK,1);
  19.         float(_declare,Hanging,0);
  20.         float(_declare,DropDelay,100);
  21.  
  22.  
  23. //keep start
  24.         if(VActiveTime==0)
  25.         {
  26.             call(AttachToActor,WeaponAbeastMachineGun,8);
  27.             Direction(_or,_DIRhavegun|_DIRcombatmode);
  28.         }
  29. //keep stop
  30.  
  31.  
  32.         //print("Turnspeed:   ",turnspeed);
  33.  
  34.         if(vtrigger==_DIRaction)
  35.         {
  36.             vector(_declare,bbbcolor,200,200,255);
  37.             vector(_declare,bbbvec,0,0,1);
  38.             //SpawnLight(Lomnilight2,0,EmptyVector,bbbcolor,EmptyVector,250);
  39.             //SpawnLight(Lplanelight,0,EmptyVector,bbbcolor,bbbvec,650);
  40.         }
  41.  
  42.         //printi("State:  ",vstate);
  43.         if(VState==StateDead)
  44.         {
  45.             Direction(_clr,_DIRaiRemoveFlags);
  46.         }
  47.         elseif(vAICon!=0)
  48.         {
  49. // **************************************************************************
  50. // **************************************************************************
  51. // **************************************************************************
  52. /*
  53.                 //AIPickDest(100,1);
  54.  
  55.                 Direction(_clr,_DIRaiRemoveFlags)
  56.  
  57.                 if(VTrigger!=_DIRHaveGun)
  58.                 {
  59.                     call(IsPickupClose,_ClassWeapon);    
  60.                     if(vtrigger==_DIRTempFlag)
  61.                     {
  62.                         Direction(_set,_DIRaction);
  63.                         //float(_set,ActionOK,1);
  64.                         //direction(_clr,_DIRactionhold);
  65.                     }
  66.                 }
  67.  
  68.                 float(_declare,shootcounter,0);
  69.                 if(vlockedondistance>30 && vaistate!=_AIstateIdle && 1==2)
  70.                 {
  71.                     print("Checking for movement");
  72.                     if(vtargetdistance>600 && vaistate==_AIstateAttack)
  73.                     {
  74.                         if(vlockedonangle<-20)
  75.                         {
  76.                             //turn(0,-19,0);
  77.                             Direction(_set,_DIRleft);
  78.                         }
  79.                         elseif(vlockedonangle>20)
  80.                         {
  81.                             //turn(0,19,0);
  82.                             Direction(_set,_DIRright);
  83.                         }
  84.                         //if(vlockedonangle<50 && vlockedonangle>-50)
  85.                         //{
  86.                             if(vlockedonangle<=20 && vlockedonangle>=-20)
  87.                             {
  88.                                 Direction(_set,_dirrun);
  89.                                 if(vstate==statenormal && vtargetdistance>1000 && vtargetdistance<1500 && vaction!=ABeastThrowGrenade && vrnd<5)
  90.                                 {
  91.                     //                Direction(_set,_DIRGrenade);
  92.                                 }
  93.                             }
  94.                         //}
  95.                     }
  96.                     else
  97.                     {
  98.                         if(vtargetdistance>100)
  99.                         {
  100.                             if(vlockedonangle<-20)
  101.                             {
  102.                                 //turn(0,-19,0);
  103.                                 Direction(_set,_DIRleft);
  104.                             }
  105.                             elseif(vlockedonangle>20)
  106.                             {
  107.                                 //turn(0,19,0);
  108.                                 Direction(_set,_DIRright);
  109.                             }
  110.                             if(vlockedonangle<90 && vlockedonangle>-90)
  111.                             {
  112.                                 //if(vlockedondistance<300)
  113.                                 if(vtrigger==_DIRhavegun)
  114.                                 {
  115.                                     if(vrnd<10 || shootcounter!=0)
  116.                                     {
  117.                                         Direction(_set,_DIRshoot);
  118.                                         float(_add,shootcounter,1);
  119.                                         if(shootcounter>60)
  120.                                         {
  121.                                             Direction(_clr,_DIRshoot);
  122.                                             float(_set,shootcounter,0);
  123.                                         }
  124.                                     }
  125.                                 }
  126.                                 else
  127.                                 {
  128.                                     Direction(_clr,_DIRshoot);
  129.                                 }
  130.                         print("Walk");
  131.                                 Direction(_set,_dirwalk);
  132.                             }
  133.                         }
  134.                         else
  135.                         {
  136.                             printi("aligning to node angle",vtargetangle);
  137.                             if(vtargetangle<-20)
  138.                             {
  139.                                 //turn(0,-19,0);
  140.                                 Direction(_set,_DIRleft);
  141.                             }
  142.                             elseif(vtargetangle>20)
  143.                             {
  144.                                 //turn(0,19,0);
  145.                                 Direction(_set,_DIRright);
  146.                             }
  147.                         }
  148.                     }
  149.  
  150.                 }
  151.  
  152.                 if(vtrigger==_DIRvercol && vstate!=StateJump)
  153.                 {
  154.                     Collision(0,-20,0, 0,-20,-130);
  155.                     if(vcolflag==_DIRvercol)
  156.                     {
  157.                         Collision(0,60,0, 0,60,-130);
  158.                         if(vcolflag!=_DIRvercol)
  159.                         {
  160.                             Direction(_set,_DIRjump);
  161.                         }
  162.                     }
  163.                 }
  164.                 elseif(vstate==StateJump)
  165.                 {
  166.                     Direction(_set,_DIRjump);
  167.                 }
  168.  
  169.                 if(VTrigger|=_DIRMoveBits)
  170.                 {
  171.                     Direction(_set,_DIRMove)
  172.                 }
  173.  
  174. // **************************************************************************
  175. // **************************************************************************
  176. // **************************************************************************
  177. */
  178.         }
  179.         else
  180.         {
  181. //Player control
  182.             call(AIupdateAIvars);            //to update aicounters like TimeNotTarget
  183.             call(AIcheckfortarget,10);        //for LineOfSight reasons etc. this is called for player character also
  184.  
  185.             if(vtrigger==_DIRpossesion)
  186.             {
  187.                 float(_set,PlayerHeadBone,4);
  188.                 callsub(Sub_InitPossesion,ABeastPossesed);
  189.             }
  190.             elseif(vtrigger==_DIRdepossesion)
  191.             {
  192.                 callsub(Sub_InitDepossesion,ABeastDepossesed)
  193.             }
  194.         }
  195.  
  196.  
  197.  
  198.         if(vstate!=StateDead)
  199.         {
  200.             callSub(Sub_ActionKeyHandler,ActionOK);
  201.             if(vstate==StateNormal && vtrigger!=_DIRhavegun)
  202.             {
  203.                 callSub(Sub_CheckActionPickup,ABeastPickup,14,0,0);
  204.                 callsub(BackGroundTriggerChecks);
  205.             }
  206.             else
  207.             {
  208.                 callsub(BackGroundTriggerChecks);
  209.                 if(vstate==StateNormal)
  210.                 {
  211.                     callSub(Sub_CheckActionDrop,ABeastPickup,14,0,0,DropDelay);
  212.                 }
  213.             }
  214.             if (vtrigger!=_DIRhavegun)
  215.             {
  216.                 callSub(Sub_CheckRemainingActions,ABeastPressGun,22);
  217.             }
  218.             else
  219.             {
  220.                 callSub(Sub_CheckRemainingActions,ABeastPressGun,22);
  221.             }
  222.  
  223.             callsub(Sub_Headtrack);                    //Track head against object
  224.  
  225.     state(_clr,StateThrown);    //XXX Oh, ohhh. Very illegal, but I don't want to deal with thrown for beasts right now, thank you.
  226.  
  227.             //if in the electric shock animations do not check for fall, it's done for you!!
  228.             if(VState!=StateElectricShock && VState!=StateThrown)
  229.             {
  230.                 CallSub(Sub_CheckFallDamage,ABeastTouchDown,FallStartAltitude,ABeastMaxFall,DamageABeastFall,ABeastFallDead,0,ABeastFallInplace);
  231.  
  232. ///////////////
  233. ///////////////
  234.                 if(vaction!=ABeastTouchDown)
  235.                 {
  236.                     float(_set,heavylandfx,0);
  237.                     float(_set,heavylandfx2,0);
  238.                 }
  239.                 if(vaction==ABeastTouchDown && heavylandfx==0 && heavylandfx2<=9)
  240.                 {
  241.                     if(heavylandfx2==0)
  242.                     {
  243.                         call(ScreenShake,0,24,0,0.5);
  244.                     }
  245.  
  246.                     vector(_set,fxvector,0,-200,0);
  247.                     call(SetParticleSetID);
  248.                     callsub(sub_shockwave,BulletShockWave,0);
  249.                 }
  250.  
  251.                 if(vaction==ABeastTouchDown)
  252.                 {
  253.                     if(heavylandfx>=3)
  254.                     {
  255.                         float(_set,heavylandfx,0);
  256.                     }
  257.                     else
  258.                     {
  259.                         float(_add,heavylandfx,1);
  260.                     }
  261.                     float(_add,heavylandfx2,1);
  262.  
  263.                 }
  264. ///////////////
  265. ///////////////
  266.  
  267.             }
  268.         }
  269.         callsub(Sub_CheckHit,ABeastWoundLight,ABeastWoundLight,ABeastWoundLightNoBreak,FireCount,ABeastPoleDead,ABeastWoundLight,0,0,0,0);
  270.  
  271.         if(vstate==StateOnFire)    //These first if-statements are just for effects
  272.         {
  273.             if(FireCount==0)
  274.             {
  275.                 float(_rnd2,ActorFireType,70);
  276.             }
  277.  
  278.             callsub(Sub_ActorFireEffect,SmokeCount,FireCount,255)
  279.         }
  280.         elseif(vstate==StateBlind)
  281.         {
  282.             if(SmokeCount==0)
  283.             {
  284.                 sample(SFXcough7,-1);
  285.             }
  286.             callsub(Sub_ActorSmokeEffect,SmokeCount,255)
  287.         }
  288.  
  289.         call(CheckAttached,_CANormal);
  290.  
  291.         if(VAction!=ABeastBurningRunInCircle&&VAction!=ABeastBurningRollOnFloor&&VAction!=ABeastSlowGetUpFace)    //It would look bad if he died while in one of these animations
  292.         {
  293. //The last number here is used if they have to fall on their knees when energy is low
  294.             callsub(Sub_CheckDeadOrDying,ABeastPoleDead,ABeastCrawlDead,ABeastStandDead,ABeastCrawlSpreadOut,0,ABeastFallToCrawl,ABeastStandDead,ABeastStandDead);    //0=health when entering crawling-mode
  295.  
  296.             if(vaction==ABeastStandDead||vaction==ABeastFallDead)
  297.             {
  298.                 if(vframe==75)
  299.                 {
  300.                     call(ScreenShake,0,24,0,0.5);
  301.                 }
  302.             }
  303.         }
  304.  
  305.  
  306.         if(vstate==StateExecuteAnim)
  307.         {
  308. //keep start
  309.             if(vaction==ABeastThrowGrenade2)
  310.             {
  311.                 if(vendofanim!=0)
  312.                 {
  313.                     callsub(Sub_SpawnGrenade);
  314.                 }
  315.                 callsub(Sub_TurnCharacter,TurnSpeed,ABeastMaxTurnSpeed,ABeastTurnAcc);
  316.             }
  317. //keep stop
  318.             elseif(vaction==ABeastPossesed)
  319.             {
  320.                 callsub(Sub_TurnCharacter,TurnSpeed,ABeastMaxTurnSpeed,ABeastTurnAcc);
  321.             }
  322.             elseif(vaction==ABeastPickup)
  323.             {
  324.               //callSub(Sub_CheckActionButton,ABeastPickup,14)
  325.             }
  326. //ABeastClimbUp, ABeastDepossesed, ABeastPickup/Throw weapon,
  327.             callsub(Sub_CheckExecuteAnimEnd)
  328.         }
  329.         elseif(vstate==StateDead||vstate==StateCrawling||vstate==StateBlind||vstate==StateOnFire||vstate==StateSteamed||vstate==StateHarpooned||vstate==StateElectricShock)
  330.         {
  331.             if(VState!=StateDead)
  332.             {
  333.                 if(vstate==StateHarpooned)    //Here are the if-statements that control the actions when you are badly wounded
  334.                 {
  335.                     callsub(Sub_Harpooned,ABeastOnPole,ABeastOnPole,ABeastOnPole,ABeastOnPole,ABeastOnPole,ABeastOnPole,0,0);
  336.                 }
  337.                 else
  338.                 {
  339.                     callsub(Sub_TurnCharacter,TurnSpeed,ABeastMaxTurnSpeedWounded,ABeastTurnAccWounded);
  340.                     if(vstate==StateCrawling)
  341.                     {
  342. //    is this where he has to roll over and hug his knees, and scream if you force him to move?
  343. //
  344.                         callsub(Sub_Crawling,ABeastCrawlSpreadOut,ABeastFallToCrawl)
  345.                     }
  346.                     elseif(vstate==StateOnFire||vstate==StateSteamed||vstate==StateBlind)
  347.                     {
  348.                         float(_declare,SteamScreamCounter,0);
  349.                         callsub(Sub_BurnedSteamedBlind,ABeastBurningRollOnFloor,ABeastBurnedIdle,ABeastGettingBurned,ABeastBlindForward,ABeastBlindBackwards,ABeastBurningRunInCircle,ABeastSlowGetUpFace,SteamScreamCounter)
  350.                     }
  351.                     elseif(vstate==StateElectricShock)
  352.                     {
  353.                         callsub(Sub_ElectricShock,ABeastelectricshock0,ABeastelectricshock1);
  354.  
  355.                         if(vaction==Abeastelectricshock0)
  356.                         {
  357.                             if(vframe==1)
  358.                             {
  359.                                 sample(SFXElectricShock1,-1);
  360.                                 call(SubtractHealth,0,DamageElectric);
  361.                             }
  362.                         }
  363.                         elseif(vaction==Abeastelectricshock1)
  364.                         {
  365.                             if(vendofanim!=0)
  366.                             {
  367.                                 sample(SFXElectricShock2,-1);
  368.  
  369.                                 call(PlaneTriggerQuadrant,TmpFloat,1);
  370.                                 if(TmpFloat==0)
  371.                                 {
  372.                                     spawnaction(ABeastThrownForward);
  373.                                     move(0,0,-150);
  374.                                 }
  375.                                 elseif(TmpFloat==1)
  376.                                 {
  377.                                     spawnaction(ABeastThrownLeft);
  378.                                     move(150,0,0);
  379.                                 }
  380.                                 elseif(TmpFloat==2)
  381.                                 {
  382.                                     spawnaction(ABeastThrownBack);
  383.                                     move(0,0,150);
  384.                                 }
  385.                                 elseif(TmpFloat==3)
  386.                                 {
  387.                                     spawnaction(ABeastThrownRight);
  388.                                     move(-150,0,0);
  389.                                 }
  390.                                 state(_change,StateElectricShock,StateThrown);
  391.                             }
  392.                         }
  393.                     }
  394.                 }
  395.             }
  396.         }
  397.         else
  398.         {
  399.             CallSub(Sub_CheckClimbUp,ABeastClimbUp,60,ColAngleCorrectNeeded,20,-10)
  400.             if(vstate==StateNormal)
  401.             {
  402.                 callsub(sub_AlignToWallAndCheckRunUpStairs,ABeastRunUpStairs,ABeastIdle,ABeastIdleHitWall,ColAngleCorrectNeeded,ABeastIdleHitWallFront,ABeastHitWallSpreadOut,-0.95,ABeastSpreadOut,ABeastSpreadOut,ForceRunFrames)
  403.                 callsub(Sub_CheckForIdleLongTime,ABeastIdle,ABeastIdleLongTime);
  404.  
  405.                 if(vendofanim!=0)
  406.                 {
  407.                     if(vaction==ABeastTouchDown)
  408.                     {
  409.                         spawnaction(ABeastIdle);
  410.                     }
  411.                 }
  412.  
  413. //keep start
  414.                 if(VTrigger==_DIRGrenade&&VInventoryLeft>0)
  415.                 {
  416.                     state(_or,StateExecuteAnim);
  417.                     spawnaction(ABeastThrowGrenade);
  418.                 }
  419. //keep stop
  420.  
  421. /*                if(VAction==ABeastStandShoot && VFrame==0)
  422.                 {
  423.                     vector(_set,TmpVector,0,0,0);
  424.                     spawnactorbone(BulletMachineGun,TmpVector,Gactorpos,Gactorine,8);
  425.                 }
  426. */
  427.                 CallSub(Sub_CheckJumpFallDown,AIAbility,ABeastRunUpStairs,JumpPressCounter,DownwardPull,ABeastJumpSpeed,ABeastJump,AirSpeedForward,AirSpeedSideways,ABeastFall,ABeastAirSpeed)
  428.                 //callSub(Sub_CheckActionButton,ABeastPickup,14)
  429.                 callsub(Sub_TurnCharacter,TurnSpeed,ABeastMaxTurnSpeed,ABeastTurnAcc);
  430.             }
  431.             elseif(vstate==StateFalling||vstate==StateJump)
  432.             {
  433.                 if(vstate==StateJump)
  434.                 {
  435.                     CallSub(Sub_Jump,JumpPressCounter,DownwardPull,15,ABeastJumpGravity,2,0)
  436.                 }
  437.                 callsub(Sub_TurnCharacter,TurnSpeed,ABeastMaxTurnSpeedAir,ABeastTurnAccAir);
  438.                 callsub(Sub_MoveInAir,AirSpeedSideways,AirSpeedForward,ABeastAirSpeed,ABeastAirBulb);
  439.             }
  440.         }
  441.         //armored beast doesn't need to do this
  442.         //callsub(FireWeaponsAndCheckAttached,ShootDelayCounter,8,ABeastHeavyRecoil,ABeastLightRecoil,0,0);
  443.  
  444.  
  445. /*
  446.  
  447. Mangler:
  448.  
  449. -        Position control for formations
  450.  
  451.  
  452.  
  453. VAIleader                            X    X
  454. VAIgroupstate                        X    X
  455. VAItargetfound                        X    X
  456. VAInringroup                        X    X
  457. VAIingroup                            X    X
  458. VAIaskedtojoin                        X    X
  459. VAIstate                            X    X
  460. VAInotargettime                        X    X
  461. VAIgrouphealth                        X    X
  462. VAItimeincurrentorder                X    X
  463. VAIlasttargetfound                    X    X
  464. VAIgroupleft                        X    X
  465. VAIhealth                            X    X
  466. VAIchangetonewgroup                    X
  467. VAIpowerrating            
  468. VAIrebel                
  469. VAIleaderaspirations
  470.  
  471. Functions:
  472. AIasktojoin(groupstate);            X    X
  473. AIcheckfortarget()                    X    X
  474. AIreleasegroup()                    X    X
  475. AIbreakfromgroup()                    X    X
  476. AIjoinnewgroup()                    X    X
  477. AIorder(groupstate)                    X    X
  478. AIpickdest(range,frequency)            X
  479. */
  480.  
  481.     if(vaicon!=0)
  482.     {
  483.         call(AIupdateAIvars);
  484.         printi("curstate  ",vstate);
  485.         if(vstate==StateFollowPath)
  486.         {
  487.             print("Follow path mode");
  488.             call(AIPickdest);        //follow path
  489.             if(vtrigger==_DIRtempflag)
  490.             {
  491.                 call(PickNewNode);
  492.             }
  493.         }
  494.         elseif(vstate==StateExecutePathSequence)
  495.         {
  496.             print("Executing path sequence");
  497.             call(AIPickdest);        //follow path
  498.             if(vtrigger==_DIRtempflag)
  499.             {
  500.                 print("End of path");
  501.                 state(_clr,StateExecutePathSequence);
  502.                 state(_or,StateFollowPath);
  503.                 call(PickNewNode);
  504.             }
  505.             //check for end of path
  506.             call(AIorder,_AIstateWork);
  507.         }
  508.         elseif(VAIleader!=0)            //in charge
  509.         {
  510. //            print("Im the leader....");
  511.             call(AIcheckfortarget);
  512.  
  513.             if(VAIgroupstate!=_AIstateidle && VAIgroupstate!=_AIstatesearch)            //search should be widened to account for all attackstates
  514.             {
  515.                 call(AIPickdest);
  516. //                printi("In attack....",VAInotargettime);
  517.                 if(VAInotargettime<AINOTARGETTHRESHOLD)
  518.                 {
  519. //                    print("Persuing enemy...");
  520.                     call(AIasktojoin,_AIstateAttack);            //to make sure newcomers are asked to join for battle
  521.                     if(VAItargetfound!=_AIenemy && VAInotargettime<AINOTARGETSEARCHTHRESHOLD)
  522.                     {
  523.                         call(AIorder,_AIstateSearch);
  524. //                        sample(SFXOrderSearch,-1);
  525.                     }
  526. /*                    elseif(VAIgrouphealth<50)
  527.                     {
  528.                         call(AIorder,_AIstateretreat);
  529.                     }
  530.                     elseif(VAIpowerrating>80)        //0=no chance 50=neutral 100=superior
  531.                     {
  532.                         call(AIorder,_AIstatesurround);
  533.                     }
  534.                     elseif(VAIpowerrating<30)        //0=no chance 50=neutral 100=superior
  535.                     {
  536.                         call(AIorder,_AIstatespreadout);
  537.                     }
  538.                     elseif(VAIpowerrating<15)
  539.                     {
  540.                         call(AIorder,_AIstatehide);
  541.                     }
  542.                     elseif(VAIgroupleft<70 || VAItimeincurrentorder>AIINORDERREGROUPTHRESHOLD)            //percentage left of original group
  543.                     {
  544.                         call(AIorder,_AIstateregroup);
  545.                     }
  546.                     else
  547.                     {
  548.                         call(AIorder,_AIstateattack);
  549.                     }
  550. */
  551.                     if(Vaistate==_AIstateattack)
  552.                     {
  553.                         print("Im leading an attack");
  554.                     }
  555.                     call(AIgrouppickdest);
  556.                 }
  557.             }
  558.             else
  559.             {
  560.                 print("No enemy in sight....");
  561.                 if(VAItargetfound==_AIenemy)        //just saw enemy
  562.                 {
  563.         //            print("I saw you. Changing to attack mode");
  564.                     call(AIselecttarget,_AIenemy);
  565.                     call(AIorder,_AIstateAttack);
  566. //                    sample(SFXOrderGetHim,-1);
  567.                 }
  568.                 elseif(VAIlasttargetfound|=_AIenemy)            //continue searching
  569.                 {
  570.         //            print("But there used to be....");
  571.                     if(VAInotargettime>AISTOPIFNOTARGETTHRESHOLD)        //check for release group
  572.                     {
  573.                         call(AIorder,_AIstateAtEase);
  574.                         call(AIreleasegroup);
  575.                         sample(SFXSSGirlAhBaNine,-1);
  576.                     }
  577.                     else
  578.                     {
  579.         //                print("So search for him....");
  580.                         if(vaistate!=_AIstatesearch)
  581.                         {
  582.                             call(AIorder,_AIstateSearch);
  583. //                            sample(SFXOrderSearch,-1);
  584.                         }
  585.                     }
  586.                 }
  587.                 else                                    //nothing in sight. no present search
  588.                 {
  589.                     //idle formations here
  590.         //            print("Leader in idle formation");
  591.                     call(AIasktojoin,_AIstateIdle);            //join the idle formation
  592.                     if(VAInringroup<5)
  593.                     {
  594.                         //special formation here
  595.                     }
  596.  
  597.                 }
  598.             }
  599.         }
  600.         elseif(VAIingroup!=0)        //included in group
  601.         {
  602. //            print("Im assigned to a group....");
  603.  
  604.             //call(AIcheckfortarget);
  605.  
  606.             if(VAIstatechanged!=0)
  607.             {
  608.                 sample(SFXOrderYesSir1,-1);
  609.             }
  610.  
  611.             if(VAIaskedtojoin!=0)
  612.             {
  613. //                printi("And im asked to leave",VAIchangetonewgroup);
  614.                 if(VAIchangetonewgroup!=0)
  615.                 {
  616.                     call(AIbreakfromgroup);
  617.                     call(AIjoinnewgroup);
  618.                 }
  619.             }
  620.             call(AIPickdest);
  621.  
  622.  
  623.         //    if(Vaistate==_AIattack)
  624.         //    {
  625.         //        print("And in the middle of an attack........");
  626.         //    }
  627.  
  628. /*            if(VAIrebel!=0)            //want out? (friendly fire, health, members dies, ammunition etc)
  629.             {
  630.                 break();
  631.                 call(AIbreakfromgroup);
  632.                 if(VAItargetfound==_AIenemy)            //in the middle of battle?
  633.                 {
  634.                     if(VAIhealth<10)
  635.                     {
  636.                         call(AIorder,_AIstateflee);
  637.                         call(AIasktojoin,_AIRetreat);
  638.                     }
  639.                     elseif(VAIhealth>90)
  640.                     {
  641.                         call(AIorder,_AIstateAttack);
  642.                         call(AIasktojoin,_AIAttack);
  643.                     }
  644.                     else
  645.                     {
  646.                         call(AIorder,_AIstateHide);
  647.                         call(AIasktojoin,_AIRetreat);
  648.                     }
  649.                 }
  650.                 else
  651.                 {
  652.                     call(AIorder,_AIstateIdle);
  653.                 }
  654.             }
  655.             elseif(VAIaskedtojoin!=0)
  656.             {
  657.                 if(VAIchangetonewgroup!=0)
  658.                 {
  659.                     break();
  660.                     call(AIbreakfromgroup);
  661.                     call(AIjoinnewgroup);
  662.                 }
  663.             }
  664.             else
  665.             {
  666.                 call(AIpickdest,100,1);        //execute order
  667.                 if(VAIstate==_AISearch)
  668.                 {
  669.                     call(AIcheckfortarget);
  670.                     if(VAItargetfound==_AIenemy)
  671.                     {
  672.                         call(AIorder,_AIstateattention);
  673.                     }
  674.                 }
  675.             }
  676. */
  677.         }
  678.         else
  679.         {
  680.             call(AIcheckfortarget);
  681.  
  682.             print("Im by my self");
  683.  
  684.             if(VAIaskedtojoin!=0)
  685.             {
  686.                 print("I was asked to join");
  687.                 if(VAIchangetonewgroup!=0)
  688.                 {
  689.                     print("I joined");
  690.                     call(AIjoinnewgroup);
  691.                     sample(SFXOrderYesSir1,-1);
  692.  
  693.                     //    spawn respond to attention
  694.                     //    then go into idle...
  695.                     //
  696. //                    if(VClass==ABeastl)
  697. //                    {
  698.                         state(_or,StateExecuteAnim);
  699.                         spawnaction(ABeastAttention);
  700. //                    }
  701.                 }
  702.                 else
  703.                 {
  704.                     printi("LeaderAspiration: ",VAIleaderaspirations);
  705.                     if(VAIleaderaspirations!=0)
  706.                     {
  707.                         printi("Ask to join new group");
  708.                         call(AIasktojoin,_AIstateAttack);
  709.                         call(AIorder,_AIstateattack);
  710.                         //sample(SFXOrderGetHim,-1);
  711.                     }
  712.                 }
  713.             }
  714.             else
  715.             {
  716.                 print("And nobody asked me to join");
  717.             }
  718.  
  719.             if(vaistate==_aistateattack)
  720.             {
  721.                 if(VAItargetfound!=0 && VAItargetfound==_AIenemy)
  722.                 {
  723.                     print("InAttack by myself...");
  724.                     call(AIselecttarget,_AIenemy);
  725.                     call(AIPickdest);                //in no group. goes after the guy by himself
  726.                 }
  727.                 else
  728.                 {
  729.                     call(AIorder,_AIstateSearch);
  730. //                    sample(SFXOrderSearch,-1);
  731.                 }
  732.             }
  733.             elseif(vaistate==_aistatesearch)
  734.             {
  735.                 print("Im searching by myself..");
  736.                 Direction(_set,_DIRright);
  737.                 if(VAItimeincurrentorder>AINOTARGETTHRESHOLD)
  738.                 {
  739.                     call(AIorder,_AIstateidle);
  740.                 }
  741.             }
  742.             elseif(VAItargetfound!=0)
  743.             {
  744.                 print("Target found");
  745.                 if(VAItargetfound==_AIenemy)
  746.                 {
  747.                     print("Enemy found...............");
  748. //    break();
  749.  
  750.                     call(AIorder,_AIstateattack);
  751.                     print("Going into attackmode...");
  752.  
  753. /*                    if(vaistate!=_aiattention)
  754.                     {
  755.                         call(AIorder,_AIstateattention);
  756.                         sample(SFXOrderOverThere1,-1);
  757.                     }
  758. */
  759.                     if(VAIleaderaspirations!=0)
  760.                     {
  761.                         call(AIasktojoin,_AIstateAttack);
  762.                         call(AIorder,_AIstateattack);
  763.                         //sample(SFXOrderGetHim,-1);
  764.                     }
  765.  
  766.                 }
  767.                 elseif(VAITargetFound==_AIundetermined)
  768.                 {
  769.                     call(AIorder,_AIstateSearch);
  770. //                    sample(SFXOrderSearch,-1);
  771.                 }
  772.                 else        //friend seen
  773.                 {
  774.             //        call(AIasktojoin,_AIstateIdle);
  775.             //        print("Friend found.Join me.........");
  776.                 }
  777.             }
  778.             else
  779.             {
  780.                 call(AIorder,_AIstateIdle);
  781.                 print("In AIIdle");
  782.                 //patrol
  783.                 //relax
  784.                 //sleep
  785.             }
  786.         }
  787.  
  788.         //print("..........................");
  789.     }
  790.  
  791.  
  792.